<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加视频</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css" />
</head>
<body>
    <form class="layui-form" action="" lay-filter="user-edit">
        <div class="mainBox">
            <div class="main-container">
                <div class="main-container">
                    <div class="layui-form-item">
                        <label class="layui-form-label">视频名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入视频名称" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">视频地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="url" lay-verify="url" autocomplete="off" placeholder="请输入视频地址" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="bottom">
            <div class="button-container">
                <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="user-save">
                    <i class="layui-icon layui-icon-ok"></i>
                    提交
                </button>
                <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </div>
    </form>
    <script src="../../../component/layui/layui.js"></script>
    <script src="../../../component/pear/pear.js"></script>
    <script>
        layui.use(['form', 'jquery', 'context', 'permission', 'popup'], function () {
            let form = layui.form;
            let $ = layui.jquery;
            let context = layui.context;
            let popup = layui.popup;

            let basePath = context.get("base-path");

            form.on('submit(user-save)', function (data) {

                $.ajax({
                    url: basePath + '/api/video/add',
                    data: JSON.stringify(data.field),
                    dataType: 'json',
                    contentType: 'application/json',
                    type: 'post',
                    success: function (result) {
                        if (result.succeeded) {
                            popup.success("修改成功", function () {
                                parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                                parent.layui.table.reload("user-table");
                            });
                        } else {
                            popup.failure("修改失败");
                        }
                    }
                })
                return false;
            });
        })
    </script>
</body>
</html>